package com.future.cb.web.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.future.cb.common.annotation.NoNeedLoginIn;
import com.future.cb.common.bean.Result;
import com.future.cb.service.AuthenticationService;

@RestController
@RequestMapping("/authentication")
public class AuthenticationController {
	@Autowired
	private AuthenticationService authenticationService;

	@RequestMapping("/authorize")
	@NoNeedLoginIn
	public Result authorize(String username, String password) {
		String token = this.authenticationService.getToken(username, password);
		return Result.ok(token);
	}
	
	@RequestMapping("/refreshtoken")
	public Result refreshtoken(String token){
		String tokennew = this.authenticationService.refreshtoken(token);
		return Result.ok(tokennew);
	}
}
